const express = require("express")
const Music = require("../../model/music")
const MusicList = require("../../model/musicList")
const Share = require("../../model/share")
const News = require('../../model/news')
const router = express.Router()


//初始化歌曲信息
router.get("/music/list", async (req, res) => {
    let skip = req.query.skip
    const musicList = await Music.find().limit(10).skip(skip * 10)
    res.send(musicList)
})
//初始化文章信息
router.get("/news/list", async (req, res) => {
    let skip = req.query.skip
    const newsList = await News.find().limit(10).skip(skip * 10)
    res.send(newsList)
})
//初始化歌单信息
router.get("/musicList/list", async (req, res) => {
    const musics = await MusicList.find().populate({
        path: 'musics'
    })
    res.send(musics)
})
//初始化分享信息
router.get("/share/list", async (req, res) => {
    const data = await Share.find().sort({ _id: -1 }).populate(
        [{
            path: 'user_id'
        },
        {
            path: 'music_id'
        },
        {
            path: 'news_id'
        }])
    res.send(data)
})






module.exports = router